
/**
 * @fileoverview Defines 'locale' namespace.
 * @link http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml
 * @link https://developers.google.com/closure/compiler/docs/js-for-compiler
 */


/**
 * Defines 'locale' namespace.
 * @namespace Defines 'locale' namespace.
 */
var locale = locale || {};


/**
 * Definition of default locale ("en").
 * @type {string}
 * @const
 */
locale.DEFAULT_LOCALE = 'en';


/**
 * Tries to extracts locale from user agent, otherwise returns DEFAULT_LOCALE.
 * @return {string} Returns user locale.
 * @see locale.DEFAULT_LOCALE
 */
locale.getLocale = function() {
  return (navigator['userLanguage'] || navigator['language'] ||
          locale.DEFAULT_LOCALE).substr(0, 2);
};
